<!DOCTYPE html>
<html lang="zh-CN" xmlns:th="http://www.thymeleaf.org">
<head th:fragment="common-header">

    <meta charset="UTF-8"/>
    <meta http-equiv="X-UA-Compatible" content="IE=edge"/>
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"/>
    <meta name="description" content="gym-management-system"/>
    <meta name="author" content="ZhangMing"/>
    <title>健身房管理系统-管理员</title>
    <link rel="icon" type="image/png" th:href="@{/img/logo.png}">

    <link rel="preconnect" href="https://fonts.googleapis.com">
    <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
    <link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;600;700&family=Roboto:wght@400;500;700&display=swap" rel="stylesheet">

    <link href="https://cdn.jsdelivr.net/npm/simple-datatables@latest/dist/style.css" rel="stylesheet"/>
    <link href="/static/css/styles.css" th:href="@{/css/styles.css}" rel="stylesheet"/>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.3/js/all.min.js"
            crossorigin="anonymous"></script>

</head>
<body>

<!--导航栏-->
<nav class="sb-topnav navbar navbar-expand navbar-dark bg-dark" th:fragment="common-navbar">
    <!-- Navbar Brand-->
    <a class="navbar-brand ps-3">
        <img th:src="@{/img/logo.png}"  style="height: 21px; margin-right: 7px;">
        健身房管理系统</a>
    <!-- Sidebar Toggle-->
    <button class="btn btn-link btn-sm order-1 order-lg-0 me-4 me-lg-0" id="sidebarToggle" href="#!"><i
            class="fas fa-bars"></i></button>
    <!-- Navbar Search-->
    <form class="d-none d-md-inline-block form-inline ms-auto me-0 me-md-3 my-2 my-md-0" id="searchForm">
        <div class="input-group">
            <input class="form-control" type="text" id="navSearchInput" placeholder="搜索功能" aria-label="搜索功能"
                   aria-describedby="btnNavbarSearch"/>
            <button class="btn btn-primary" id="btnNavbarSearch" type="submit"><i class="fas fa-search"></i></button>
        </div>
    </form>
    <!-- Navbar-->
    <ul class="navbar-nav ms-auto ms-md-0 me-3 me-lg-4">
        <li class="nav-item dropdown">
            <a class="nav-link dropdown-toggle" id="navbarDropdown" href="#" role="button" data-bs-toggle="dropdown"
               aria-expanded="false"><i class="fas fa-user fa-fw"></i></a>
            <ul class="dropdown-menu dropdown-menu-end" aria-labelledby="navbarDropdown">
                <li><a class="dropdown-item" th:href="@{/}"><i class="fas fa-sign-out-alt"></i>&nbsp;退出登录</a></li>
            </ul>
        </li>
    </ul>
</nav>

<!--侧边栏-->
<div id="layoutSidenav_nav" th:fragment="common-sidenav">
    <nav class="sb-sidenav accordion sb-sidenav-light" id="sidenavAccordion">
        <div class="sb-sidenav-menu">
            <div class="nav">

                <!--快速查询区域-->
                <div class="sb-sidenav-menu-heading">快速查询</div>
                <a class="nav-link" th:href="@{/member/toSelByCard}" data-searchtext="会员卡查询 卡查询">
                    <div class="sb-nav-link-icon"><i class="fas fa-id-card"></i></div>
                    会员卡查询
                </a>

                <!--管理区域-->
                <div class="sb-sidenav-menu-heading">管理</div>
                <a class="nav-link" th:href="@{/member/selMember}" data-searchtext="会员管理 会员 会员信息 会员资料 会员列表">
                    <div class="sb-nav-link-icon"><i class="fas fa-user"></i></div>
                    会员管理
                </a>
                <a class="nav-link" th:href="@{/employee/selEmployee}" data-searchtext="员工管理 员工 员工信息 员工资料 员工列表 职员管理">
                    <div class="sb-nav-link-icon"><i class="fas fa-user-tie"></i></div>
                    员工管理
                </a>
                <a class="nav-link" th:href="@{/equipment/selEquipment}" data-searchtext="器材管理 器材 器械 设备管理 器材列表 器械列表">
                    <div class="sb-nav-link-icon"><i class="fas fa-table-tennis"></i></div>
                    器材管理
                </a>
                <a class="nav-link" th:href="@{/class/selClass}" data-searchtext="课程管理 课程 排课 课程列表 课程信息 课程安排 选课">
                    <div class="sb-nav-link-icon"><i class="fas fa-calendar-alt"></i></div>
                    课程管理
                </a>
                <a class="nav-link" th:href="@{/admin/toUpdatePassword}" data-searchtext="修改密码 密码 改密码 更改密码 修改密码">
                    <div class="sb-nav-link-icon"><i class="fas fa-key"></i></div>
                    修改密码
                </a>


                <!--链接区域-->
                <div class="sb-sidenav-menu-heading">链接</div>
                <a class="nav-link" href="https://gitee.com/siqi0631/test/" data-searchtext="项目地址 项目">
                    <div class="sb-nav-link-icon"><i class="fab fa-github"></i></div>
                    项目地址
                </a>
            </div>
        </div>

        <div class="sb-sidenav-footer">
            <div class="small">你好！</div>
            管理员
        </div>
    </nav>
</div>

<!--页脚-->
<footer class="py-4 bg-light mt-auto" th:fragment="common-footer">
    <div class="container-fluid px-4">
        <div class="d-flex align-items-center justify-content-between small">
            <div class="text-muted">Copyright &copy; GYM 2025</div>
        </div>
    </div>
</footer>

<div th:fragment="common-scripts">
    <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/js/bootstrap.bundle.min.js"
            crossorigin="anonymous"></script>
    <script src="/static/js/scripts.js" th:src="@{/js/scripts.js}"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.8.0/Chart.min.js" crossorigin="anonymous"></script>
    <script src="/static/assets/demo/chart-area-demo.js" th:src="@{/assets/demo/chart-area-demo.js}"></script>
    <script src="/static/assets/demo/chart-bar-demo.js" th:src="@{/assets/demo/chart-bar-demo.js}"></script>
    <script src="https://cdn.jsdelivr.net/npm/simple-datatables@latest" crossorigin="anonymous"></script>
    <script src="/static/js/datatables-simple-demo.js" th:src="@{/js/datatables-simple-demo.js}"></script>

    <script>
        document.addEventListener('DOMContentLoaded', function() {
            // 获取搜索表单和输入框
            const searchForm = document.getElementById('searchForm');
            const searchInput = document.getElementById('navSearchInput');

            // 阻止表单默认提交行为
            searchForm.addEventListener('submit', function(e) {
                e.preventDefault();
                performSearch();
            });

            // 也可以为按钮添加点击事件（如果不想用表单提交）
            document.getElementById('btnNavbarSearch').addEventListener('click', function() {
                performSearch();
            });

            // 执行搜索函数
            function performSearch() {
                const searchTerm = searchInput.value.trim().toLowerCase();
                if (!searchTerm) return;

                // 获取所有导航链接
                const navLinks = document.querySelectorAll('.nav-link[data-searchtext]');
                let matchedLink = null;

                // 遍历所有链接，检查是否匹配搜索词
                navLinks.forEach(link => {
                    const searchText = link.getAttribute('data-searchtext').toLowerCase();
                    if (searchText.includes(searchTerm)) {
                        matchedLink = link;
                        return; // 找到第一个匹配项就停止
                    }
                });

                // 如果找到匹配项，跳转到对应页面
                if (matchedLink) {
                    window.location.href = matchedLink.href;
                } else {
                    alert('未找到匹配的功能，请尝试其他关键词');
                }
            }

            // 可选：添加键盘事件，按Enter键触发搜索
            searchInput.addEventListener('keypress', function(e) {
                if (e.key === 'Enter') {
                    performSearch();
                }
            });
        });
    </script>
</div>

</body>
</html>